<?php
$this->breadcrumbs = array(
    Shop::t('Products'),
);
Shop::renderFlash();
$currentPage = $pages->getCurrentPage()+1;

?>

<div class="sub-page">
    <h2>We found <span class="red-text"><strong><?php echo $item_count;?></strong></span> result(s) for "<span class="red-text"><strong><?php echo Yii::app()->session['keyword'];?></strong></span>"</h2>
    <div class="paging-block marT2">
        <p>Displaying <?php echo $pages->getCurrentPage()* $page_size +1;?>  to <?php echo ($item_count >= (($pages->getCurrentPage()+1) * $page_size))?($pages->getCurrentPage()+1) * $page_size : $item_count;?> (of <?php echo $item_count?> products)</p>

        <div class="pages">
            <?php
            // the pagination widget with some options to mess
            $this->widget('MyLinkPager', array(
                'currentPage' => $pages->getCurrentPage(),
                'itemCount' => $item_count,
                'pageSize' => $page_size,
                'maxButtonCount' => 5,
                'header' => '',
                'htmlOptions' => array('class' => 'pages'),
            ));
            ?>
        </div>
    </div>
    <div class="all-product">
        <?php foreach ($model as $key => $data) { 
            $data['price'] = intval(($data['price'])?$data['price'] + $data['frame']['price_adjustion']:$data['price']);
            $data['new_price'] = intval(($data['new_price'])?$data['new_price'] + $data['frame']['price_adjustion']:$data['new_price']);
        ?>
            <div class="prd-textt">
                <div class="prd-textt-pict">
                    <span class="large-pict"><a href="<?php echo $this->createUrl('/shop/products/view', array('id'=>$data['product_id']))?>"><img
                                src="<?php echo Yii::app()->request->baseUrl ?>/data/upload/products/<?php echo isset($data->shopImages[0]) ? $data->shopImages[0]->filename : 'no_image.jpg'?>"
                                width="260" height="260"></a></span>
                </div>
                <div class="prd-detail">
                    <p>Date Added: <?php echo date('l t F, Y', strtotime($data['created_time'])) ?></p>
                    <hr>
                    <h2><a href="<?php echo $this->createUrl('/shop/products/view', array('id'=>$data['product_id']))?>"><?php echo $data['title'] ?></a></h2>

					<p class="label"><strong>Product Code:</strong> <?php echo $data['product_code'] ?></p>
					
                    <p class="label"><strong>Manufacturer:</strong> <?php echo $data['manufacturer'] ?> </p>

                    <p class="label"><strong>Weight:</strong> <?php echo $data['weight'] ?>gram</p>

                    <p class="label"><strong>Size:</strong> <?php echo $data['size'] ?>(cm)</p>

                    <p class="marT20">
                        <span style="margin:7px 15px 0 0" class="floatL"><strong>Price:</strong></span>
                        <?php if ($data['price'] && $data['new_price']) { ?>
                            <span class="old-price">$<?php echo $data['price'] ?></span>
                            <span class="new-price">$<?php echo $data['new_price'] ?></span>
                        <?php } else { ?>
                            <span class="new-price">$<?php echo ($data['price'])?$data['price']:'' ?></span>
                        <?php } ?>
                    </p>

                    <div class="clearB"></div>
                    <?php if ($data['stock']):?>
                    	<a class="red-button marT20 buy-now" rel="<?php echo ($data['frame']['price_adjustion'])? $data['product_id'] .'-1':$data['product_id'] .'-0';?>" href="javascript:void(0)">Buy now</a>
                    <?php else :?>
                    	<br />
                    	<p class="label"><span class="small-pict red-text">Out of Stock</span></p>
                    <?php endif;?>
                </div>
            </div>
        <?php } ?>
    </div>
    <div class="paging-block">
        <p>Displaying <?php echo $pages->getCurrentPage()* $page_size +1;?>  to <?php echo ($item_count >= (($pages->getCurrentPage()+1) * $page_size))?($pages->getCurrentPage()+1) * $page_size : $item_count;?> (of <?php echo $item_count?> products)</p>

        <div class="pages">
            <?php
            // the pagination widget with some options to mess
            $this->widget('MyLinkPager', array(
                'currentPage' => $pages->getCurrentPage(),
                'itemCount' => $item_count,
                'pageSize' => $page_size,
                'maxButtonCount' => 5,
                'header' => '',
                'htmlOptions' => array('class' => 'pages'),
            ));
            ?>
        </div>
    </div>
</div>